#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <iterator>
using namespace std;

class Bignum
{
private:
	vector <int> body;
	int length;
public:	
	Bignum(int num);
	Bignum(char *s);
	void setnum(char *s);
	bool iszero(); 	/* 检查是否为零函数 */
	void output(); 	/* 输出函数 */
	friend bool     operator ==(const Bignum & b1, const Bignum & b2);
	friend bool     operator >(const Bignum & b1, const Bignum & b2);
	friend bool     operator <(const Bignum & b1, const Bignum & b2);
	friend Bignum   operator +(Bignum  b1, Bignum  b2); /* 大整数加法运算函数 */
	friend Bignum   operator -(Bignum  b1, Bignum  b2); /* 大整数减法运算函数 */
	friend Bignum   operator *(Bignum  b1, Bignum  b2); /* 大整数乘法运算函数 */
	friend Bignum   operator *(Bignum  b1, int a);			  /* 大整数除法调用函数，大整数乘一般整数 */
//	friend Bignum   operator /(const Bignum & b1, const Bignum & b2); /* 大整数除法运算函数 */
//	friend Bignum   operator %(const Bignum & b1, const Bignum & b2); /* 大整数取余运算函数 */

};

Bignum::Bignum(int num=0) /* 构造函数 */
{	    
    do
    {
        body.push_back(num % 10);
        num /= 10;
    }while (num != 0);    
    length = body.size();
}

Bignum::Bignum(char *s)
{
    int len;
    len = strlen(s) - 1;
    while (len >= 0)    
        body.push_back( s[len--] - '0');
    length = body.size();    
}    

void Bignum::setnum(char *s)  /* 置数函数 */
{
	int len;
	body.clear();
    len = strlen(s) - 1;
    while (len >= 0)    
        body.push_back( s[len--] - '0');
    length = body.size();   
}

void Bignum::output() /* 输出函数 */
{
	int i;
	for (i=length-1; i>=0; --i)
		cout << body[i];	
}

bool Bignum::iszero() /* 检查是否为零函数 */
{
    if (length == 1 && body[0] == 0)
    	return true;
   	return false;
}    

bool     operator == (const Bignum & b1, const Bignum & b2)
{
    int i;
    if (b1.length != b2.length) return false;
    for (i=b1.length-1; i>=0; --i)
    	if (b1.body[i] != b2.body[i])
    		return false;
    return true;
}    

bool     operator >(const Bignum & b1, const Bignum & b2)
{
    int i;
    if (b1.length != b2.length) return (b1.length > b2.length);
    for (i=b1.length-1; i>=0; --i)
    	if (b1.body[i] != b2.body[i])
   			return (b1.body[i] > b2.body[i]);
    return false;
}    

bool     operator <(const Bignum & b1, const Bignum & b2)
{
	int i;
    if (b1.length != b2.length) return (b1.length < b2.length);
    for (i=b1.length-1; i>=0; --i)
    	if (b1.body[i] != b2.body[i])
   			return (b1.body[i] < b2.body[i]);
    return false;
}    

Bignum  operator + (Bignum b1, Bignum b2) /* 大整数加法运算函数 */
{
    int i, len;
    Bignum to(0);
    
    len = b1.length > b2.length ? b1.length : b2.length ;
    
    to.body.resize(len+1);
    b1.body.resize(len+1);
    b2.body.resize(len+1);
    for (i=0; i<len; ++i)
    {
        to.body[i] += b1.body[i] + b2.body[i];
        if (to.body[i] > 9)
        {
            to.body[i+1] += to.body[i]/10;
            to.body[i] %= 10;
        }    
    }    
    if (to.body[len] > 0) len++;   
    to.length = len; 
    return to;
}

Bignum  operator -(Bignum b1, Bignum b2) /* 大整数减法运算函数 */
{
    int i, len;
    Bignum to(0);
    
    len = b1.length;
    to.body.resize(len);
    b2.body.resize(len);
    for (i=0; i<len; ++i)
    {
        to.body[i] += b1.body[i] - b2.body[i];
        if (to.body[i] < 0)
        {
            to.body[i] += 10;
            to.body[i+1] --;
        }    
    }    
    while (to.body[len] == 0 && len >= 1) len--;
    to.length = len + 1;
    return to;
}    

Bignum  operator *(Bignum b1, int a) /* 大整数除法调用函数，大整数乘一般整数 */
{
    int i, len;
    Bignum to(0);
    
    len = b1.length;
    to.body.resize(len+50);
    for (i=0; i<len; ++i)
    {
        to.body[i] += b1.body[i] * a;
        if (to.body[i] > 9)
        {
            to.body[i+1] += to.body[i] / 10;
            to.body[i] %= 10;
        }    
    }    
  
    while (to.body[len] > 9 )
    {
        to.body[len+1] += to.body[len] / 10;
        to.body[len] %= 10;
        len ++;
    }    
    while (to.body[len] == 0 && len >= 1) len --;
    to.length = len + 1;
    return to;
}    

Bignum  operator * (Bignum b1, Bignum  b2) /* 大整数乘法运算函数 */
{
    int i, j, k, len;
    Bignum to(0);
    
    len = b1.length + b2.length + 1;
    to.body.resize(len+1);
    for (i=0; i<b1.length; ++i)
    	for (j=0; j<b2.length; ++j)
    	{
    	    k = i + j ;
    	    to.body[k] += b1.body[i] * b2.body[j];
    	    if (to.body[k] > 9)
    	    {
    	        to.body[k+1] += to.body[k] / 10;
    	        to.body[k] %= 10;
    	    }    
    	}    
    
    while (to.body[len] == 0 && len >= 1) len--;
    to.length = len+1;
    return to;
}   


vector <Bignum> number;


void init()
{
    int i;
    Bignum board(10);	
	Bignum f1(1), f2(2), f3(0);
	
	for (i=1; i<=100; ++i)	board = board * 10;
	number.push_back(f3);
	number.push_back(f1);
	number.push_back(f2);	
	
	while (f3 < board)
	{
	    f3 = f1 + f2;
	    number.push_back(f3);
	    f1 = f2;
	    f2 = f3;
	}    
}    

void deal()
{
    char s1[105], s2[105];
    Bignum  a(0), b(0);
    int  count, i;
    bool out;
    while (1)
    {
        cin >> s1 >> s2;
        a.setnum(s1);
        b.setnum(s2);
        if (a.iszero() && b.iszero()) break;
        count = 0;        
        for (i=1,out=false; i<number.size() && !out; ++i)
        {
        	if (a < number[i] || a== number[i])  
        	{
         		if (b>number[i] || b == number[i]) count ++;
           		else out = true;  
            }  		
        }   
        cout << count << endl; 
        
    }    
}    

int main()
{
	init();
	deal();

   // system("pause");
	return 0;    
}    





